package com.lc.cehui.ui.fragment.home;

import android.widget.ImageView;

import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lc.cehui.R;
import com.lc.cehui.app.AppFragment;
import com.lc.cehui.http.glide.GlideApp;
import com.lc.cehui.http.response.TechnologyShowBean;
import com.lc.cehui.other.IntentKey;
import com.lc.cehui.ui.activity.home.TrainingDetailsActivity;
import com.lc.cehui.util.SPUtil;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class TeachFragment extends AppFragment<TrainingDetailsActivity> {

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    private TechnologyShowBean data;
    private BaseQuickAdapter adapter;
    private List<TechnologyShowBean.DataBean.TeacherBean> datalist=new ArrayList<>();
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_teach;
    }

    @Override
    protected void initView() {
        Gson gson = new Gson();
        data = gson.fromJson(SPUtil.get(getContext(), IntentKey.TEXT, ""), new TypeToken<TechnologyShowBean>() {
        }.getType());

        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
 recyclerView.setAdapter(adapter =new BaseQuickAdapter<TechnologyShowBean.DataBean.TeacherBean, BaseViewHolder>(R.layout.adapter_teachlist,data.getData().getTeacher())

    {
        @Override
        protected void convert (@NonNull BaseViewHolder baseViewHolder, TechnologyShowBean.DataBean.TeacherBean
        bean){
            GlideApp.with(getActivity())
                    .load(bean.getImg())
                    .placeholder(R.mipmap.mine_default_avatar)
                    .error(R.mipmap.mine_default_avatar)
                    .transform(new MultiTransformation<>(new CenterCrop(), new CircleCrop()))
                    .into((ImageView) baseViewHolder.getView(R.id.im_logo));
        baseViewHolder.setText(R.id.tv_title, bean.getTeach());
        baseViewHolder.setText(R.id.tv_money, bean.getDes() );


    }
    });

}
    @Override
    protected void initData() {

    }
}
